<?php
declare (strict_types = 1);

namespace app\http;


class OnRequestEvent
{
    /**
     * @var Server
     */
    protected $server;

    /**
     * @var App
     */
    protected $app;


    public function __construct(\think\App $app, \Swoole\Server $server)
    {
        $this->server = $server;
        $this->app    = $app;
    }


    public function handle(\Swoole\Http\Request $request, \Swoole\Http\Response $response)
    {
        // 遍历获取所有的fd
        foreach ($this->server->connections as $fd) {
            $this->server->send($fd,1111);
            // 这里就可以执行推送了
        }
    }
}